<template>

    <div class="brand-wrapper">
        <!--      查询表单 -->
        <div class="search-form">
            <el-form :inline="true" class="demo-form-inline" size="mini">
                <el-form-item label="赠品名称">
                    <el-input placeholder="请输入赠品名称" v-model="searchParams.giftsName"></el-input>
                </el-form-item>

                <el-form-item label="选择商品分类">
                    <!--动态渲染  选择品牌-->
                    <el-select  placeholder="选择商品分类" v-model="searchParams.typeId">
                        <el-option v-for="(item,index) in typeList" :key="index" :label="item.typeName"
                                   :value="item.id"></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="选择品牌">
                    <!--动态渲染  选择品牌-->
                              <el-select  placeholder="选择品牌" v-model="searchParams.brandId">
                                  <el-option v-for="(item,index) in brandList" :key="index" :label="item.brandName"
                                             :value="item.id"></el-option>
                              </el-select>
                </el-form-item>
                <el-form-item label="选择颜色">
                    <!--动态渲染  选择品牌-->
                    <el-select  placeholder="选择颜色" v-model="searchParams.giftsColor">
                        <el-option v-for="(item,index) in colorList" :key="index" :label="item.colorName"
                                   :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="选择类型">
                    <!--动态渲染  选择品牌-->
                    <el-select  placeholder="选择类型" v-model="searchParams.productId">
                        <el-option v-for="(item,index) in modelList" :key="index" :label="item.productModel"
                                   :value="item.id"></el-option>
                    </el-select>
                </el-form-item>


                <!--        <el-form-item label="活动区域">-->
                <el-form-item>
                    <el-button type="primary" @click="searchPage">查询</el-button>
                    <el-button type="warning" @click="resetForm">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <!--    操作功能 -->
        <div class="crud-box">
            <el-button type="primary" size="mini" icon="el-icon-edit" @click="dialogVisible=true,formData={},selectIds=[]">新建</el-button>
            <el-button type="success" size="mini" icon="el-icon-edit" :disabled="batchIds.length!=1" @click="dialogVisible=true">修改</el-button>
            <el-button type="danger" size="mini" icon="el-icon-delete" :disabled="batchIds.length<=0"
                       @click="showBatchDeleteDialog">删除
            </el-button>
        </div>


        <!--    表格数据-->
        <!--:tree-props="{children: 'children'
            row-key="id"
         树状结构 children-->
        <div class="data-box">
            <el-table
                    :data="tableData"
                    style="width: 100%"
                    @selection-change="selectChange">
                <el-table-column
                        align="center"
                        type="selection"
                        width="55">
                </el-table-column>

                <el-table-column type="expand">
                    <template slot-scope="props">
                        <el-form label-position="left" inline class="demo-table-expand">
                            <el-form-item label="赠品编码">
                                <span>{{ props.row.giftsId }}</span>
                            </el-form-item>
                            <el-form-item label="品牌名称">
                                <span>{{ props.row.brandId }}</span>
                            </el-form-item>
                            <el-form-item label="赠品颜色">
                                <span>{{ props.row.giftsColor }}</span>
                            </el-form-item>
                            <el-form-item label="类别名称">
                                <span>{{ props.row.typeId }}</span>
                            </el-form-item>
                            <el-form-item label="产品型号">
                                <span>{{ props.row.productId }}</span>
                            </el-form-item>
                            <el-form-item label="采购部门">
                                <span>{{ props.row.buyDepartment }}</span>
                            </el-form-item>
                            <el-form-item label="最低库存数">
                                <span>{{ props.row.minNumber }}</span>
                            </el-form-item>
                            <el-form-item label="购买成本">
                                <span>{{ props.row.buyPrice }}</span>
                            </el-form-item>
                            <el-form-item label="赠品单价">
                                <span>{{ props.row.sellPrice }}</span>
                            </el-form-item>
                            <el-form-item label="最低备货数">
                                <span>{{ props.row.minNumber }}</span>
                            </el-form-item>
                            <el-form-item label="赠品状态">
                                <span>{{ props.row.giftsStatus }}</span>
                            </el-form-item>
                        </el-form>
                    </template>
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="giftsName"
                        label="赠品名称"
                        width="180">
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="productId"
                        label="商品类型">
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="minNumber"
                        label="最低库存数">
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="sellPrice"
                        label="赠品单价">
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="buyPrice"
                        label="购买成本">
                </el-table-column>
                <el-table-column
                        align="center"
                        prop="giftsStatus"
                        label="赠品状态">
                </el-table-column>
                <el-table-column

                        label="操作">
                    <template v-slot="hanjie">
                        <el-button type="primary" size="mini" icon="el-icon-edit" @click="dialogVisible=true,formData.giftsId=hanjie.row.giftsId,findById()"></el-button>
                        <el-popconfirm
                                confirm-button-text='确定'
                                cancel-button-text='取消'
                                icon="el-icon-info"
                                icon-color="red"
                                @confirm="deleteById"
                                placement="top"
                                title="是否要删除本条记录？"
                        >
                            <el-button slot="reference" type="danger" size="mini" @click="formData.giftsId=hanjie.row.giftsId"
                                       icon="el-icon-delete"></el-button>
                        </el-popconfirm>
                    </template>
                </el-table-column>
            </el-table>

        </div>


        <!--    分页-->
        <div class="page-box">
            <el-pagination
                    background
                    layout="prev, pager, next"
                    :total="total"
                    :page-size="searchParams.pageSize"
                    :current-page="searchParams.currentPage"
                    @current-change="currentPageChange"
            >
            </el-pagination>

        </div>

        <!--弹框-->
        <el-dialog
                title="实体操作"
                :visible.sync="dialogVisible"
                width="38%"
        >
            <el-form ref="form" label-width="80px" :model="formData" size="small">
                <el-tabs v-model="activeName">
                    <!--element ui 的 Tabs 标签页 -->
                        <el-form-item label="赠品名称">
                            <el-input v-model="formData.giftsName"></el-input>
                        </el-form-item>
                    <el-form-item label="选择商品分类">
                        <!--动态渲染  选择品牌-->
                        <el-select  placeholder="选择商品分类" v-model="formData.typeId">
                            <el-option v-for="(item,index) in typeList" :key="index" :label="item.typeName"
                                       :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="选择类型">
                        <!--动态渲染  选择品牌-->
                        <el-select  placeholder="选择类型" v-model="formData.productId">
                            <el-option v-for="(item,index) in modelList" :key="index" :label="item.productModel"
                                       :value="item.id"></el-option>
                        </el-select>
                    </el-form-item>
                        <el-form-item label="赠品单价">
                            <el-input v-model="formData.sellPrice"></el-input>
                        </el-form-item>
                        <el-form-item label="购买成本">
                            <el-input v-model="formData.buyPrice"></el-input>
                        </el-form-item>
                        <el-form-item label="采购部门">
                            <el-input v-model="formData.buyDepartment"></el-input>
                        </el-form-item>
                    <el-form-item label="最低库存数">
                        <el-input v-model="formData.minNumber"></el-input>
                    </el-form-item>
                    <!--<el-form-item label="赠品状态">-->
                        <!--<el-input v-model="formData.giftsStatus"></el-input>-->
                    <!--</el-form-item>-->
                    <el-form-item label="选择赠品状态">
                        <!--动态渲染  选择品牌-->
                        <el-select  placeholder="选择赠品状态" v-model="formData.giftsStatus">
                            <el-option value="0">失效</el-option>
                            <el-option value="1">有效</el-option>
                        </el-select>
                    </el-form-item>
                        <el-form-item label="选择颜色">
                            <!--动态渲染  选择品牌-->
                            <el-select  placeholder="选择颜色" v-model="formData.giftsColor">
                                <el-option v-for="(item,index) in colorList" :key="index" :label="item.colorName"
                                           :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="选择品牌">
                            <!--动态渲染  选择品牌-->
                            <el-select  placeholder="选择品牌" v-model="formData.brandId">
                                <el-option v-for="(item,index) in brandList" :key="index" :label="item.brandName"
                                           :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                </el-tabs>
            </el-form>


            <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" size="mini" @click="dialogVisible = false,addOrEdit()">确 定</el-button>
  </span>
        </el-dialog>
    </div>

</template>

<script>
import gift from "./index";

export  default  gift;
</script>

<!--src 引用css样式-->
<style src="./index.scss"  lang="scss"></style>